import fs from 'fs'
import request from 'request'

const url = 'https://imis.gxyq.top/serve/v1/open/user/release'
const webPath = 'E://huyuanbiao//pc//LL002-ZHR-WEB-FRONTEND//web.zip'

const requestApi = () => {
    const options = {
        method: 'POST',
        url,
        headers: {
            'Accept-Encoding': 'gzip,deflate',
            'content-type': 'multipart/form-data; boundary=---011000010111000001101001'
        },
        formData: {
            file: {
                value: fs.createReadStream(webPath),
                options: {
                    filename: 'web.zip',
                    contentType: null
                }
            }
        }
    };
    return new Promise((resolve, reject) => {
        request(options, (error, response, body) => {
            if (error) {
                console.log(`接口请求失败:${error}`);
                reject(error)
            }
            console.log(`接口请求成功:${body}`);
            resolve(body)
        });
    })
}

export const reqApi = async () => {
    await requestApi()
}

